import { message } from "antd"

/**
 * 给 null值 或者 undefined 重新赋值为 空字符串
 */
export const assignUndefinedValue = (value) => {
    return value ? value : ""
}

/**
 * 重新加载页面
 */
export const refresh = () => {
    window.location.reload()
}

/**
 * 日历组件的配置
 */
export const configLocale = {
    "lang": {
        "locale": "zh_CN",
        "placeholder": "请选择日期",
        "rangePlaceholder": ["开始日期", "结束日期"],
        "today": "今天",
        "now": "现在",
        "backToToday": "返回到今天",
        "ok": "OK",
        "clear": "清除",
        "month": "月",
        "year": "年",
        "timeSelect": "选择时间",
        "dateSelect": "请选择日期",
        "monthSelect": "选择月份",
        "yearSelect": "选择年份",
        "decadeSelect": "选择年代",
        "yearFormat": "YYYY",
        "dateFormat": "M/D/YYYY",
        "dayFormat": "D",
        "dateTimeFormat": "M/D/YYYY HH:mm:ss",
        "monthFormat": "MMMM",
        "monthBeforeYear": true,
        "previousMonth": "上个月 (上箭头)",
        "nextMonth": "下个月 (下箭头)",
        "previousYear": "去年 (Control + 左箭头)",
        "nextYear": "明年 (Control + 右箭头)",
        "previousDecade": "过去十年",
        "nextDecade": "未来十年",
        "previousCentury": "过去一个世纪",
        "nextCentury": "未来一个世纪",
        "shortWeekDays": ["周末", "周一", "周二", "周三", "周四", "周五", "周六"],
        "shortMonths": [
            "一月",
            "二月",
            "三月",
            "四月",
            "五月",
            "六月",
            "七月",
            "八月",
            "九月",
            "十月",
            "十一月",
            "十二月"
        ]
    },
    "timePickerLocale": {
        "placeholder": "选择时间"
    },
    "dateFormat": "YYYY-MM-DD",
    "dateTimeFormat": "YYYY-MM-DD HH:mm:ss",
    "weekFormat": "YYYY-wo",
    "monthFormat": "YYYY-MM"

}

/**
 * 复制文本
 */
export const copy = (value) => {
    navigator.clipboard.writeText(value).then(() => {
        message.success('复制成功！');
    });
}